import React, { Suspense } from 'react'
import ReactDOM from 'react-dom/client'
import { HashRouter, Route, Routes } from 'react-router-dom'
import Layout from '@/components/layout';
import projectConf from './conf/project.conf';
import './style.css'

/** 懒加载组件 */
const lazyComponent = (Elm: any) => <Suspense fallback={<div></div>}><Elm /></Suspense>
/** 路由配置 */
const routeMap = [
  {p: '/', c: lazyComponent(React.lazy(() => import('@/components/view/Home')))},
]
// 设置页面标题
document.title = projectConf.name;
// 挂载路由
ReactDOM.createRoot(document.getElementById('root')!).render(<>
  <HashRouter>
    <Layout>
      <Routes>
        {routeMap.map(item => <Route path={item.p} key={item.p} element={ item.c } />)}
      </Routes>
    </Layout>
  </HashRouter>
</>);
